﻿using NovoSerDes.A2B.STNodeControls;
using ST.Library.UI.NodeEditor;
using STNode_A2B.STNodeControls;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NovoSerDes.A2B.STNodes
{
    [STNode("A2B")]
    public class STNode_Comment : STNode
    {
        private STNodeControl_TextBox ctrl_TextBox;

        private string _comment;
        [STNodeProperty("Comment", "Comment")]
        public String Text
        {
            get
            {
                return _comment;
            }
            set
            {            
                ctrl_TextBox.EditorText = value;
                _comment = value;
                Invalidate();           
            }
        }

        private string _nodeName = "Comment";
        [STNodeProperty("Title", "Title")]
        public string NodeName
        {
            get { return _nodeName; }
            set
            {
                this._nodeName = value;
                this.Title = this._nodeName;
            }
        }
        protected override void OnCreate()
        {
            base.OnCreate();
            this.Title = "Comment";
            this.TitleColor = Color.FromArgb(200, Color.Goldenrod);
            this.AutoSize = false;
            this.Size = new Size(180, 50);

            ctrl_TextBox = new STNodeControl_TextBox();
            ctrl_TextBox.IsIntData = false;
            ctrl_TextBox.DisplayRectangle = new Rectangle(5, 5, 170, 25);
            ctrl_TextBox.EditorText = Text;
            ctrl_TextBox.MouseClick += (s, e) =>
            {
                TextBoxForm textBoxForm = new TextBoxForm();
                textBoxForm.ShowMessage(Text);
                textBoxForm.Show();
                textBoxForm.FormClosed += (sa, ea) => {
                    ctrl_TextBox.EditorText = textBoxForm.GetText();
                    this.Text = textBoxForm.GetText();
                };

            };

            this.Controls.Add(ctrl_TextBox);
        }
    }
}
